﻿using System;
using System.Collections.Generic;
using System.Text;
using YouHP.BLL;
using YouHP.Utility;
using YouHP.Model;
using System.Text.RegularExpressions;
using System.Web;

namespace YouHP.Pages.User
{
    public class PatientLogs : UserBasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();
            if (this.ErrorCount > 0) return;

            HandleCommon();
            if (IsPost) HandlePost();
            else HandleGet();
        }

        protected List<LogTopicInfo> LogDataList;
        protected List<VisitRecordInfo> LattestVisitRecordList;
        protected PatientRecordInfo PrData;
        protected DiseaseInfo DiseaseData;
        protected int PageIndex = 1;
        protected int PageSize = 20;
        protected int DataCount = 0;
        protected int PageCount = 0;
        protected string PagingString = "";

        protected void HandleCommon()
        {

            LattestVisitRecordList = UserBLL.Instance.GetLattestVisitRecordList(UserData.Id, 6);
            PrData = PatientBLL.Instance.GetPatientRecordInfo(UserData.Id);
            DiseaseData = DiseaseBLL.Instance.GetDiseaseInfo(PrData.DiseaseId);
            this.SetTitle(DiseaseData.Name + "病人的日志");
            this.AddLocation("<font color=\"red\">" + DiseaseData.Name + "</font>" + "&nbsp;病人的日志", "");
        }

        protected void HandlePost()
        {

        }

        protected void HandleGet()
        {
            PageIndex = RequestTools.GetQueryInt("page", 1);
            LogDataList = LogTopicBLL.Instance.GetLogTopicListByDiseaseId(PageSize, PageIndex, PrData.DiseaseId, out DataCount);
            PageCount = Utils.GetPageCount(DataCount, PageSize);

            string query = HttpContext.Current.Request.Url.Query;
            query = Utils.RemoveQueryItem(query, "page");

            PagingString = this.GetPagingString(
                PageIndex,
                PageCount,
                "/User/PatientLogs.aspx" + query, "page");
        }
    }
}